<?php
$cid        = gpc_getStringArray('cid');
$names       = "";

if(count($cid)==0)
{
    $cid[0]=$id;
}

foreach($cid as $id)
{
    //---------------Lay thong tin ve categories sap xoa
    $sql_select = "SELECT cName,iParentId FROM tblcategory WHERE iId = '$id'";
    $rs=$dbsql->query($sql_select);
    if($result = $dbsql->fetch_array($rs))
    {
    	$name           = $result["cName"];
        $names         .= $name.", ";
        $idparent       = $result['iParentId'];
    }
    $pagetr = empty($pagetr) ? "id=$idparent" : $pagetr;

    if(hasChildCategory($id))
    {
    	$msg = "Can't Delete Category [ $name ] (has Child Category)";
     	error_transfer($msg,$pagetr);
    	exit();

    }
    else if (hasChildContentNews($id))
    {
    	$msg = "Can't Delete Category  [ $name ] (has Child Content)";
     	error_transfer($msg,$pagetr);
    	exit();
    }

    $sql_delete = "DELETE FROM tblcategory WHERE iId ='$id'";
    $dbsql->query($sql_delete);

}
Insert_Tracking(" Del Category News: $names");

page_transfer("Delete Category [ $names ] Success",$pagetr);
exit();
?>